
* This do file replicates Figure 4, about historical family types and labor market indicators

/* Structure of the do file:
1. For each year for which we have data, open the dataset, generate relevant variables, run the regression, and store the estimated coefficients
2. Generate Figure 5 using the stored estimated coefficients
*/





*************************
* 1975
*************************

use "Datasets/00_rawdata/cis_1092_replication.dta", replace

* Three cities: 1 - Madrid (nuclear family province) ; 2 - Barcelona (stem family province); 3 - Sevilla (nuclear family province)
gen stem_dum = 0 
replace stem_dum = 1 if municipality_name == "Barcelona"

*** Gender inequality in general

** Survey Question: "Do you believe that there is discrimination between men and women in Spanish legislation? 1 (yes); 2 (no); 3 (DK/DA)"
tab p2

gen gender_inequality = . 
replace gender_inequality = 1 if p2 == 1
replace gender_inequality = 0 if p2 == 2

*Normalize
norm gender_inequality, method(mmx)

* Regression 
reg mmx_gender_inequality stem, r
estimates store gi_1975_norm


*** Gender inequality in politics

** Survey Question: "In what area of Spanish legislation does discrimination between men and women exist? (1) - Labor law; (2) - Political Law; (3) Civil Law; (4) Labor and Civil Law; (5) Labor and Political Law; (6) Political and Civil Law; (7) Political, Labor, and Civil Law; (8) Anywhere; (9) DK/DA"
tab p3, nolab

gen women_underrepresented = 0 if p3 !=9
replace women_underrepresented = 1 if p3==2 | p3 == 5 | p3 == 6 | p3 == 7 

*Normalize
norm women_underrepresented, method(mmx)

* Regression
reg mmx_women_underrepresented stem, r
estimates store wu_1975_norm


**************************
* YEAR 1990
**************************

use "Datasets/00_rawdata/cis_1867_replication.dta", replace

*** Indicator variable for stem family province

gen stem_dum = 0 
replace stem_dum = 1 if prov_name == "Alava"
replace stem_dum = 1 if prov_name == "Barcelona"
replace stem_dum = 1 if prov_name == "Girona"
replace stem_dum = 1 if prov_name == "Guipuzcoa"
replace stem_dum = 1 if prov_name == "Huesca"
replace stem_dum = 1 if prov_name == "Lleida"
replace stem_dum = 1 if prov_name == "Navarra"
replace stem_dum = 1 if prov_name == "Tarragona"
replace stem_dum = 1 if prov_name == "Vizcaya"


*** Prejudice againt women in politics

** Survey Question: "Thinking about the possible reasons why there are so few women holding political positions in our country, I am going to read you some opinions, and I would like you to tell me whether you tend to agree or tend to disagree: Women are not sufficiently prepared for politics. 1 (tend to agree) - 2 (tend to disagree)." (8 and 9 DK/DA)
tab p22a

gen women_unfit = . 
replace women_unfit = 1 if p22a == 1
replace women_unfit = 0 if p22a == 2

* Normalization
norm women_unfit, method(mmx)

* Regression
reg mmx_women_unfit stem, r
estimates store prejudice_1990_unfit



**************************
* YEAR 1995
**************************

use "Datasets/00_rawdata/cis_2194_replication.dta", replace

*** Indicator variable for stem family province
gen stem_dum = 0 
replace stem_dum = 1 if prov_name == "Alava"  
replace stem_dum = 1 if prov == "Barcelona"   
replace stem_dum = 1 if prov == "Girona"  
replace stem_dum = 1 if prov == "Guipuzcoa"  
replace stem_dum = 1 if prov == "Huesca"  
replace stem_dum = 1 if prov == "Lleida"  
replace stem_dum = 1 if prov == "Navarra"  
replace stem_dum = 1 if prov == "Tarragona"  
replace stem_dum = 1 if prov == "Vizcaya" 


*** Gender inequality in general

** Survey Question: "How would you rate the inequalities between men and women? 1 - very significant; 4 - almost non-existent." (8 and 9 DK/DA)
tab p7

gen gender_inequality = . 
replace gender_inequality = 0 if p7== 4
replace gender_inequality = 1 if p7 == 3
replace gender_inequality = 2 if p7 == 2
replace gender_inequality = 3 if p7 == 1

tab gender_inequality

**normalization
norm gender_inequality, method(mmx)

* Regression
reg mmx_gender_inequality stem, r
estimates store gi_1995_norm


*** Gender inequality in politics

** Survey Question: "Do you believe that the situation of women is better, the same, or worse than that of men in terms of...: Access to positions of responsibility in political life? 1 - better; 2 - same; 3 - worse." (8 and 9 DK/DA)
tab p908

gen women_underrepresented = . 
replace women_underrepresented = 1 if p908 == 1
replace women_underrepresented = 2 if p908 == 2
replace women_underrepresented = 3 if p908 == 3

* Normalization
norm women_underrepresented, method(mmx)

* Regression
reg mmx_women_underrepresented stem, r
estimates store wu_1995_norm



**************************
* YEAR 2002
**************************

use "Datasets/00_rawdata/cis_2448_replication.dta", clear

*** Indicator variable for stem family province
gen stem_dum = 0 
replace stem_dum = 1 if prov_name == "Alava" 
replace stem_dum = 1 if prov_name == "Barcelona"    
replace stem_dum = 1 if prov_name == "Girona" 
replace stem_dum = 1 if prov_name == "Guipuzcoa"  
replace stem_dum = 1 if prov_name == "Huesca"  
replace stem_dum = 1 if prov_name == "Lleida" 
replace stem_dum = 1 if prov_name == "Navarra"  
replace stem_dum = 1 if prov_name == "Tarragona"  
replace stem_dum = 1 if prov_name == "Vizcaya"  


*** Gender inequality in general

** Survey Question: "Let's now talk about the situation of women in Spain. How would you rate the inequalities that currently exist between men and women in our country: 1-very significant; 2-fairly significant; 3- small; 4-almost non-existent?" (8 and 9 DK/DA)
tab p11

gen gender_inequality = . 
replace gender_inequality = 0 if p11== 4
replace gender_inequality = 1 if p11 == 3
replace gender_inequality = 2 if p11 == 2
replace gender_inequality = 3 if p11 == 1

* Normalization
norm gender_inequality, method(mmx)

* Regression 
reg mmx_gender_inequality stem, r
estimates store gi_2002_norm


*** Gender inequality in politics

** Survey Question: "And when it comes to advancing and reaching leadership positions [in politics], do women face more (1), the same (2), or fewer difficulties (3) than men?" (8 and 9 DK/DA)
tab p1511

gen women_underrepresented = . 
replace women_underrepresented = 1 if p1511 == 3
replace women_underrepresented = 2 if p1511 == 2
replace women_underrepresented = 3 if p1511 == 1

* Normalization
norm women_underrepresented, method(mmx)

* Regression
reg mmx_women_underrepresented stem, r
estimates store wu_2002_norm


**************************
* YEAR 2005
**************************

use "Datasets/00_rawdata/cis_2597_replication.dta", clear

*** Indicator variable for stem family province
gen stem_dum = 0 
replace stem_dum = 1 if prov_name == "Alava"
replace stem_dum = 1 if prov_name == "Barcelona"
replace stem_dum = 1 if prov_name == "Girona"
replace stem_dum = 1 if prov_name == "Guipuzcoa"
replace stem_dum = 1 if prov_name == "Huesca"
replace stem_dum = 1 if prov_name == "Lleida"
replace stem_dum = 1 if prov_name == "Navarra"
replace stem_dum = 1 if prov_name == "Tarragona"
replace stem_dum = 1 if prov_name == "Vizcaya"

*** Gender inequality in general

** Survey Question: "Let's now talk about the situation of women in Spain in general: How would you rate the inequality that currently exists between men and women in our country: 1 - very significant; 4 - almost non-existent?" (8 and 9 DK/DA)
tab p2

gen gender_inequality = . 
replace gender_inequality = 0 if p2== 4
replace gender_inequality = 1 if p2 == 3
replace gender_inequality = 2 if p2 == 2
replace gender_inequality = 3 if p2 == 1

* Normalize
norm gender_inequality, method(mmx)

* Regression
reg mmx_gender_inequality stem, r
estimates store gi_2005_norm


*** Gender inequality in politics

** Survey Question: "Do you believe that the situation of women in Spain today is better (1), the same (2), or worse (3) than that of men in terms of [access to positions of political responsibility]?" (8 and 9 DK/DA)
tab p408

gen women_underrepresented = . 
replace women_underrepresented = 1 if p408 == 1
replace women_underrepresented = 2 if p408 == 2
replace women_underrepresented = 3 if p408 == 3

* Normalize
norm women_underrepresented, method(mmx)

* Regression
reg mmx_women_underrepresented stem, r
estimates store wu_2005_norm


*** Prejudice against women in politics

** Survey Question: "Nowadays, there is talk about including the same number of women as men on electoral lists and in party leadership positions. I am going to read you some statements on this topic, and I would like you to tell me whether you tend to agree or tend to disagree: 'If there are no women in leadership bodies, it is because they are not qualified.' (1) agree, (2) nor agree/disagree; (3) disagree." (8 and 9 DK/DA)
tab p904

gen women_unqualified = . 
replace women_unqualified = 0 if p904 == 3
replace women_unqualified = 1 if p904 == 2
replace women_unqualified = 2 if p904 == 1

* Normalize
norm women_unqualified, method(mmx)

* Regression
reg mmx_women_unqualified stem, r
estimates store prejudice_2005_unfit



**************************
* YEAR 2010
**************************

use "Datasets/00_rawdata/cis_2831_replication.dta", clear

*** Indicator variable for stem family province
gen stem_dum = 0 
replace stem_dum = 1 if prov_name == "Alava"
replace stem_dum = 1 if prov_name == "Barcelona"
replace stem_dum = 1 if prov_name == "Girona"
replace stem_dum = 1 if prov_name == "Guipuzcoa"
replace stem_dum = 1 if prov_name == "Huesca"
replace stem_dum = 1 if prov_name == "Lleida"
replace stem_dum = 1 if prov_name == "Navarra"
replace stem_dum = 1 if prov_name == "Tarragona"
replace stem_dum = 1 if prov_name == "Vizcaya"


*** Gender inequality in general

** Survey Question: "Let's now talk about the situation of women in Spain in general: How would you rate the inequality that currently exists between men and women in our country: 1 (very significant)- 5 (non-existent)?" (8 and 9 DK/DA)
tab p8 

gen gender_inequality = . 
replace gender_inequality = 0 if p8== 5
replace gender_inequality = 1 if p8 == 4
replace gender_inequality = 2 if p8 == 3
replace gender_inequality = 3 if p8 == 2
replace gender_inequality = 4 if p8 == 1

* Normalize
norm gender_inequality, method(mmx)

* Regression
reg mmx_gender_inequality stem, r
estimates store gi_2010_norm


*** Gender inequality in politics

** Survey Question: "Do you believe that the situation of women in Spain today is better (1), the same (2), or worse (3) than that of men in terms of [access to positions of political responsibility]?" (8 and 9 DK/DA)
tab p1108

gen women_underrepresented = . 
replace women_underrepresented = 1 if p1108 == 1
replace women_underrepresented = 2 if p1108 == 2
replace women_underrepresented = 3 if p1108 == 3

* Normalize
norm women_underrepresented, method(mmx)

* Regression
reg mmx_women_underrepresented stem, r
estimates store wu_2010_norm


*** Prejudice againt women in politics

** Survey Question: "The Equality Law passed in 2007 calls for a balanced number of women and men to be included on electoral lists and in party leadership positions. I am going to read you some statements on this topic, and I would like you to tell me whether you tend to agree or tend to disagree with each of them: ... 'If there are women in leadership bodies today, it is because they are not qualified.' (1) in agreement; (2) nor agree/disagree; (3) in disagreement." (8 and 9 DK/DA)
tab p1704

gen women_unqualified = . 
replace women_unqualified = 0 if p1704 == 3
replace women_unqualified = 1 if p1704 == 2
replace women_unqualified = 2 if p1704 == 1

* Normalize
norm women_unqualified, method(mmx)

* Regression
reg mmx_women_unqualified stem, r
estimates store prejudice_2010_unfit



**************************
* YEAR 2011
**************************


use "Datasets/00_rawdata/cis_2911_replication.dta", clear

*** Indicator variable for stem family province
gen stem_dum = 0 
replace stem_dum = 1 if prov_name == "Alava"
replace stem_dum = 1 if prov_name == "Barcelona"
replace stem_dum = 1 if prov_name == "Girona"
replace stem_dum = 1 if prov_name == "Guipuzcoa"
replace stem_dum = 1 if prov_name == "Huesca"
replace stem_dum = 1 if prov_name == "Lleida"
replace stem_dum = 1 if prov_name == "Navarra"
replace stem_dum = 1 if prov_name == "Tarragona"
replace stem_dum = 1 if prov_name == "Vizcaya"

*** Gender inequality in general

** Survey Question: "Do you believe that in Spain the inequalities in rights and opportunities among the following groups are very significant, fairly significant, small, or almost non-existent: ... 'Betweem men and women' 1 (large inequality) - 4 (almost non-existing)." (8 and 9 DK/DA)
tab P1701

gen gender_inequality = . 
replace gender_inequality = 0 if P1701== 4
replace gender_inequality = 1 if P1701 == 3
replace gender_inequality = 2 if P1701 == 2
replace gender_inequality = 3 if P1701 == 1

* Normalize
norm gender_inequality, method(mmx)
reg mmx_gender_inequality stem, r

* Regression
estimates store gi_2011_norm



*** Gender inequality in politics

** Survey Question: "And do you believe that the current situation of women in Spain is better, the same, or worse than that of men in terms of access to positions of political responsibility? 1 (better) - 3 (worse)." (8 and 9 DK/DA)
tab P2508

gen women_underrepresented = . 
replace women_underrepresented = 1 if P2508 == 1
replace women_underrepresented = 2 if P2508 == 2
replace women_underrepresented = 3 if P2508 == 3

* Normalize
norm women_underrepresented, method(mmx)

* Regression
reg mmx_women_underrepresented stem, r
estimates store wu_2011_norm


**************************
* YEAR 2016 - METROSCOPIA
**************************

use "Datasets/00_rawdata/metroscopia_15077_replication.dta", clear

*** Indicator variable for stem family province
gen stem_dum = 0 
replace stem_dum = 1 if prov_name == "Alava"
replace stem_dum = 1 if prov_name == "Barcelona"
replace stem_dum = 1 if prov_name == "Girona"
replace stem_dum = 1 if prov_name == "Guipuzcoa"
replace stem_dum = 1 if prov_name == "Huesca"
replace stem_dum = 1 if prov_name == "Lleida"
replace stem_dum = 1 if prov_name == "Navarra"
replace stem_dum = 1 if prov_name == "Tarragona"
replace stem_dum = 1 if prov_name == "Vizcaya"


*** Gender inequality in politics

** Survey Question: "Currently in Spain, how do you think the situation of women compares to that of men in... [Access to positions of political responsibility] 1 (better for women) - 3 (worse for women)." (8 and 9 DK/DA)

tab ig3_6

gen women_underrepresented = ig3_6
replace women_underrepresented = . if ig3_6 == 8
replace women_underrepresented = . if ig3_6 == 9

* Normalize
norm women_underrepresented, method(mmx)

* Regression
reg mmx_women_underrepresented stem, r
estimates store wu_2016_norm



************************
* Year 2017
************************

use "Datasets/00_rawdata/cis_3182_replication.dta", clear

*** Indicator variable for stem family province
gen stem_dum = 0 
replace stem_dum = 1 if prov_name == "Alava"
replace stem_dum = 1 if prov_name == "Barcelona"
replace stem_dum = 1 if prov_name == "Girona"
replace stem_dum = 1 if prov_name == "Guipuzcoa"
replace stem_dum = 1 if prov_name == "Huesca"
replace stem_dum = 1 if prov_name == "Lleida"
replace stem_dum = 1 if prov_name == "Navarra"
replace stem_dum = 1 if prov_name == "Tarragona"
replace stem_dum = 1 if prov_name == "Vizcaya"

*** Gender inequality in general

** Survey Question: "Let's now talk about the situation of women in Spain in general. How would you rate the inequalities that currently exist between men and women in our country: very significant, fairly significant, small, or almost non-existent? 1 (very significant) - 4 (almost non-existent)." (8 and 9 DK/DA)
tab p1

gen gender_inequality = . 
replace gender_inequality = 0 if p1== 4
replace gender_inequality = 1 if p1 == 3
replace gender_inequality = 2 if p1 == 2
replace gender_inequality = 3 if p1 == 1

* Normalize
norm gender_inequality, method(mmx)

* Regression
reg mmx_gender_inequality stem, r
estimates store gi_2017_norm



************************
* Year 2020
************************

use "Datasets/00_rawdata/cis_3273_replication.dta", clear

gen stem_dum = 0 
replace stem_dum = 1 if prov_name == "Alava"
replace stem_dum = 1 if prov_name == "Barcelona"
replace stem_dum = 1 if prov_name == "Girona"
replace stem_dum = 1 if prov_name == "Guipuzcoa"
replace stem_dum = 1 if prov_name == "Huesca"
replace stem_dum = 1 if prov_name == "Lleida"
replace stem_dum = 1 if prov_name == "Navarra"
replace stem_dum = 1 if prov_name == "Tarragona"
replace stem_dum = 1 if prov_name == "Vizcaya"


*** Gender inequality in general

** Survey Question: "In general, do you believe there is still a lot, quite a bit, little, or no progress left to make to achieve equality in rights and opportunities between men and women? 1 (There is still a long way to go) - 5 (There is no progress left to make)." (8 and 9 DK/DA)
tab b22

gen gender_inequality = . 
replace gender_inequality = 0 if b22 == 5
replace gender_inequality = 1 if b22 == 4
replace gender_inequality = 2 if b22 == 3
replace gender_inequality = 3 if b22 == 2
replace gender_inequality = 4 if b22 == 1

* Normalize 
norm gender_inequality, method(mmx)

* Regression
reg mmx_gender_inequality stem, r
estimates store gi_2020_norm


********************************************
* FIGURE 5
********************************************

*** Gender inequality in general
coefplot (gi_1975_norm, label("1975")) (gi_1995_norm, label("1995")) (gi_2002_norm, label("2002")) (gi_2005_norm, label("2005")) (gi_2010_norm, label("2010")) (gi_2011_norm, label("2011")) (gi_2017_norm, label("2017")) (gi_2020_norm, label("2020")), drop(_cons) yline(0) vertical xtitle() coeflabels(stem_dum = `"Survey Year"') ytitle(Marginal Effect of Stem Family Tradition)
graph export "Figures/Figure5a.pdf", replace

*** Gender inequality in politics
coefplot (wu_1975_norm, label("1975")) (wu_1995_norm, label("1995")) (wu_2002_norm, label("2002")) (wu_2005_norm, label("2005")) (wu_2010_norm, label("2010")) (wu_2011_norm, label("2011")) (wu_2016_norm, label("2016")), drop(_cons) xline(0) vertical yline(0) coeflabels(stem_dum = `"Survey Year"') ytitle(Marginal Effect of Stem Family Tradition)
graph export "Figures/Figure5b.pdf", replace

*** Prejudice againt women in politics
coefplot (prejudice_1990_unfit, label("1990")) (prejudice_2005_unfit, label("2005")) (prejudice_2010_unfit, label("2010")), drop(_cons) xline(0) vertical yline(0) coeflabels(stem_dum = `"Survey Year"') ytitle(Marginal Effect of Stem Family Tradition)
graph export "Figures/Figure5c.pdf", replace


